#include "lookingtingswidget.h"

LookingTingsWidget::LookingTingsWidget(QWidget *parent) : QWidget(parent)
{
    this->init_Widget();
   this->init_Control();
   this->init_Connect();
}

void LookingTingsWidget::init_Control()
{
    this->tingsCountBtn=new QPushButton();
    this->tingsCountBtn->setText(QString::fromUtf8("库存汇总"));

    this->tingsWarningBtn=new QPushButton();
    this->tingsWarningBtn->setText(QString::fromUtf8("预警存货"));

    this->tingsSearhingBtn=new QPushButton();
    this->tingsSearhingBtn->setText(QString::fromUtf8("物品搜索"));

    this->returnBtn=new QPushButton();
    this->returnBtn->setText(QString::fromUtf8("返回"));


    this->VLay=new QVBoxLayout();
    this->VLay->addWidget(this->tingsCountBtn);
    this->VLay->addWidget(this->tingsWarningBtn);
    this->VLay->addWidget(this->tingsSearhingBtn);
    this->VLay->addWidget(this->returnBtn);

    this->HLay=new QHBoxLayout();
    this->HLay->addStretch(1);
    this->HLay->addLayout(VLay);
    this->HLay->addStretch(1);

    this->setLayout(this->HLay);
}

void LookingTingsWidget::init_Widget()
{
    this->setWindowTitle(QString::fromUtf8("用户界面"));
    this->resize(800,600);
    tingsCountWidget=new TingsCountWidget();
    tingsWarningWidget=new TingsWarningWidget();
    tingsSearhingWidget=new TingsSearhingWidget();

}

void LookingTingsWidget::init_Connect()
{
    connect(this->tingsCountBtn,SIGNAL(clicked()),this,SLOT(on_tingsCountBtn_cliked()));
    connect(this->tingsWarningBtn,SIGNAL(clicked()),this,SLOT(on_tingsWarningBtn_cliked()));
    connect(this->tingsSearhingBtn,SIGNAL(clicked()),this,SLOT(on_tingsSearhingBtn_cliked()));
    connect(this->returnBtn,SIGNAL(clicked()),this,SLOT(on_returnBtn_cliked()));
    connect(this->tingsCountWidget,SIGNAL(returnWidget()),this,SLOT(showMyself()));
    connect(this->tingsWarningWidget,SIGNAL(returnWidget()),this,SLOT(showMyself()));
    connect(this->tingsSearhingWidget,SIGNAL(returnWidget()),this,SLOT(showMyself()));
}

void LookingTingsWidget::on_tingsCountBtn_cliked()
{
    this->hide();
    this->tingsCountWidget->show();

}

void LookingTingsWidget::on_tingsWarningBtn_cliked()
{
    this->hide();
    this->tingsWarningWidget->show();
}

void LookingTingsWidget::on_tingsSearhingBtn_cliked()
{
    this->hide();
    this->tingsSearhingWidget->show();
}

void LookingTingsWidget::on_returnBtn_cliked()
{
    emit returnManager();
}

void LookingTingsWidget::showMyself()
{
    //qDebug()<<"收到信号";
    this->tingsCountWidget->close();
    this->tingsWarningWidget->close();
    this->tingsSearhingWidget->close();
    this->show();
}
